{extend name="layout" /}
{block name="content"}
<div class="col-sm-8 blog-main">
            <div class="blog-post">
                <div style="display:inline-flex">
                    <h2 class="blog-post-title">{$post_info.title}</h2>
                    {if $post_info && $Think.session.uid==$post_info.uid}
                    <!--TODO 交互没做好,要有一个是否删除的选项框!!!-->
                    <a style="margin: auto"  href="/posts/{$post_info.id}/edit">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    </a>
                    <a style="margin: auto"  href="/posts/{$post_info.id}/delete">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                    </a>
                    {/if}
                </div>

                <p class="blog-post-meta">{$post_info.update_time|date='Y-m-d'} by <a href="/user/{$post_info.uid}">{$post_info->user->nickname}</a></p>

                <p>{$post_info.content|raw}</p>
                {if $post_info.uid !== $Think.session.uid}
                <div>
                    {if $zan}
                        <a href="/posts/{$post_info.id}/unzan" type="button" class="btn btn-default btn-lg">取消赞</a>
                    {else/}
                        <a href="/posts/{$post_info.id}/zan" type="button" class="btn btn-primary btn-lg">赞</a>
                    {/if}
                </div>
                {/if}
            </div>

            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">评论</div>

                <!-- List group -->
                <ul class="list-group">
                    {volist name="comments" id='comment'}

                    <li class="list-group-item">
                        <h5>{$comment.create_time} by
                            <a href="">{$comment.user.nickname}</a> {if $comment.pid!==0}回复 {$comment.pname.nickname}{/if}
                            <a href="" data-target="#exampleModal" style="float:right" data-toggle="modal" data-whatever="{$comment.id}" data-name="{$comment.user.nickname}">回复</a>
                        </h5>
                        <div>
                            {$comment.content}
                        </div>
                    </li>
                    {/volist}
                </ul>
            </div>
    <!--模态框-->
    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
        <div class="modal-dialog" id="modalDialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="exampleModalLabel">New message</h4>
                </div>
                <div class="modal-body">
                    <form action="/reply" method="post">
                        <input type="hidden" name="__token__" value="{$Request.token}">
                        <input type="hidden" name="pid" value="">
                        <input type="hidden" name="post_id" value="{$post_info.id}">
                        <div class="form-group">
                            <textarea class="form-control" id="message-text" rows="9" name="content"></textarea>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" id="submit-btn">发送</button>
                </div>
            </div>
        </div>
    </div>


    <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">发表评论</div>

                <!-- List group -->
                <ul class="list-group">
                    <form action="/posts/comment" method="post">
                        <input type="hidden" name="__token__" value="{$Request.token}">
                        <input type="hidden" name="post_id" value="{$post_info.id}"/>
                        <li class="list-group-item">
                            <textarea name="content" class="form-control" rows="10"></textarea>
                            <button class="btn btn-default" type="submit">提交</button>
                        </li>
                    </form>

                </ul>
            </div>

        </div><!-- /.blog-main -->
{/block}
<!--<script src="/static/js/frontend/post/show.js"></script>-->
{block name="footerscript"}
<script src="https://cdn.bootcss.com/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="/static/js/frontend/post/show.js"></script>
{/block}